package com.yike.user.service.impl;

import com.yike.user.entity.OpenDoorRecord;
import com.yike.user.mapper.OpenDoorRecordMapper;
import com.yike.user.service.OpenDoorRecordService;
import com.yike.user.param.OpenDoorRecordPageParam;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.yike.common.base.BaseServiceImpl;
import com.yike.common.pagination.Paging;
import com.yike.common.pagination.PageInfo;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.metadata.OrderItem;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yike.user.vo.OpenDoorRecordVo;
import org.springframework.transaction.annotation.Transactional;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.beans.factory.annotation.Autowired;

/**
 * 店铺开门记录表 服务实现类
 *
 * @author Sakura
 * @since 2024-09-04
 */
@Slf4j
@Service
public class OpenDoorRecordServiceImpl extends BaseServiceImpl<OpenDoorRecordMapper, OpenDoorRecord> implements OpenDoorRecordService {

    @Autowired
    private OpenDoorRecordMapper openDoorRecordMapper;

    @Transactional(rollbackFor = Exception.class)
    @Override
    public boolean saveOpenDoorRecord(OpenDoorRecord openDoorRecord) throws Exception {
        return super.save(openDoorRecord);
    }

    @Transactional(rollbackFor = Exception.class)
    @Override
    public boolean updateOpenDoorRecord(OpenDoorRecord openDoorRecord) throws Exception {
        return super.updateById(openDoorRecord);
    }

    @Transactional(rollbackFor = Exception.class)
    @Override
    public boolean deleteOpenDoorRecord(Long id) throws Exception {
        return super.removeById(id);
    }

    @Override
    public Paging<OpenDoorRecordVo> getOpenDoorRecordPageList(OpenDoorRecordPageParam openDoorRecordPageParam) throws Exception {
        Page<OpenDoorRecord> page = new PageInfo<>(openDoorRecordPageParam);
        IPage<OpenDoorRecordVo> iPage = openDoorRecordMapper.getOpenDoorRecordList(page, openDoorRecordPageParam);
        return new Paging<OpenDoorRecordVo>(iPage);
    }

}
